// pages/orderStep2/orderStep2.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hidden: true,
    searchinput: '',
    passWord: '',
    passWordArr: [],
    focus:false,
    isHidden: true
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  cancel: function () {
    this.setData({
      hidden: true,
      passWord: '',
      passWordArr: [],
      searchinput: ''
    });
  },

  /**
   * 盛基通支付
   */
  sjPay: function () {
    this.setData({
      hidden: false,
      focus: true,
      isHidden: false
    });
  },
  onChangeInput: function (e) {
    if (e.detail.value.length > this.data.passWord.length) {
      this.data.passWordArr.push(true);
    } else if (e.detail.value.length < this.data.passWord.length) {
      this.data.passWordArr.pop();
    }
    this.setData({
      passWord: e.detail.value,
      passWordArr: this.data.passWordArr
    });
    let that = this;
    if (e.detail.value.length >= 6) {
      wx.showToast({
        title: '支付成功',
        icon: 'success',
        duration: 3000,
        success: function (){
          that.goPaySuccessfulPage();
          
        }
      })
      return;




      wx.showToast({
        title: '密码：' + this.data.passWord,
        icon: 'succes',
        duration: 1000,
        mask: true
      })
      this.setData({
        hidden: true,
        passWord: '',
        passWordArr: [],
        searchinput: '',
        focus: false,
        isHidden: true
      })
      return;
    }
    
  },

  /**
   * 取消支付
   */
  cancelPay: function(){
    this.setData({
      hidden: true,
      passWord: '',
      passWordArr: [],
      searchinput: '',
      isHidden: true
    })
  },

  /**
   * 支付成功
   */
  goPaySuccessfulPage: function() {
    wx.navigateTo({
      url: '../../pages/paySuccessful/paySuccessful',
    })
    return;
    let that = this;
    //关闭输入密码窗口
    that.setData({
      hidden: true
    })
    wx.showModal({
      title: '提示',
      content: '您输入的密码错误！',
      cancelText: '重新输入',
      confirmText: '立即设置',
      confirmColor: '#3CC51F',
      success: function (res) {
        if (res.confirm) {
          console.log('立即设置')
        } else if (res.cancel) {
          that.setData({
            passWord: '',
            passWordArr: [],
            searchinput: '',
            hidden: false,
            focus: true
          })
        }
      }
    })
  }

})